<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Title           Album library
 *
 * @package        appworkz
 * Location        application/frontend/libraries/photo
 *
 * @author         Ruwan - ruwanpathmalal@gmail.com
 * @copyright      appworkz
 *
 * created on      28-12-2012, 10:30AM by Ruwan
 * updated on      dd-mm-yyy, hh:mm by {name}
 *
 * Description     Functionalities associate with album
 *
 * */

class Album
{

    /**
     * CodeIgniter global
     *
     * @var string
     **/
    protected $ci;


    /**
     * __construct
     *
     * @param none
     * @access public
     * @return void
     * @author Ruwan - ruwanpathmalal@gmail.com
     **/
    public function __construct() {
        $this->ci =& get_instance();
        $this->ci->load->model('photo/album_model');
    }


    /**
     * __call
     *
     * Acts as a simple way to call model methods without loads of stupid alias'
     *
     * @param $method
     * @param $arguments
     * @access public
     * @return array
     * @author Ruwan - ruwanpathmalal@gmail.com
     **/
    public function __call($method = NULL, $arguments = NULL)
    {
        if (!method_exists( $this->ci->album_model, $method) )
        {
            throw new Exception('Undefined method Album::' . $method . '() called');
        }
        return call_user_func_array( array($this->ci->album_model, $method), $arguments);
    }





    /**
     * This will cerates a new photo album
     *
     * @param array $data
     * @return int last inserted id
     * @author Ruwan - ruwanpathmalal@gmail.com
     **/
    public function create($data = array()) {
        return $this->ci->album_model->add($data);
    }

    /**
     * This checks whether the user has already created an album with the provided name and album type
     *
     * @param string $business_id
     * @param int $album_name
     * @param int $album_type
     * @access public
     * @return boolean
     * @author Ruwan - ruwanpathmalal@gmail.com
     **/
    public function is_available($business_id,$album_name,$album_type) {
    	return $this->ci->album_model->is_available($business_id,$album_name,$album_type);
    }

    /**
     * Update the album details
     *
     * @param int $album_id
     * @param array $data
     * @access public
     * @return boolean
     * @author Ruwan - ruwanpathmalal@gmail.com
     **/
    public function update($album_id,$data) {
		return $this->ci->album_model->update($album_id, $data);
    }

    /**
     * Remove an album entirely
     *
     * @param int $album_id
     * @access public
     * @return boolean
     * @author Ruwan - ruwanpathmalal@gmail.com
     **/
    public function delete($album_id) {
		return $this->ci->album_model->update($album_id,array('IsDelete'=>1));
    }

    /**
     * Remove an album entirely
     *
     * @param int $business_id
     * @param string $album_name
     * @param int $type
     * @access public
     * @return boolean
     * @author Ruwan - ruwanpathmalal@gmail.com
     **/
    public function get_album_by_filters($business_id,$album_name,$type) {
    	return $this->ci->album_model->get_album_id_by_filters($business_id,$album_name,$type);
    }
    
    /**
     * Remove an album entirely
     *
     * @param array $filters
     * @param int $offset
     * @param int $limit
     * @access public
     * @return array
     * @author Ruwan - ruwanpathmalal@gmail.com
     **/
    public function get_albums($filters=array(),$offset=NULL,$limit=NULL) {
    	return $this->ci->album_model->get_albums($filters,$offset,$limit);
    }
}

/* End of file Album.php */
/* Location: ./application/frontend/libraries/activity/photo/Album.php */